package com.jcl.recruit.channel.mapper;

import com.jcl.recruit.channel.model.ChannelNet;
import com.jcl.core.utils.StringUtils;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

/**
 * @ClassName ChannelNetProvider

 * @Author yyliu
 * @Date 2018/9/11 16:50
 * @Version 1.0
 **/
public class ChannelNetProvider {

    public String insertSelective(ChannelNet channelNet){

        BEGIN();
        INSERT_INTO("channel_net");

        if(StringUtils.hasLength(channelNet.getAccount())){
            VALUES("account", "#{account, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getAccountName())){
            VALUES("account_name", "#{accountName, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getPassword())){
            VALUES("password", "#{password, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getChannelDic())){
            VALUES("channel_dic", "#{channelDic, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getChannelType())){
            VALUES("channel_type", "#{channelType, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getCorpCode())){
            VALUES("corp_code", "#{corpCode, jdbcType=VARCHAR}");
        }
        if(null != channelNet.getAddUser()){
            VALUES("add_user", "#{addUser, jdbcType=INTEGER}");
        }
        if(null != channelNet.getStatus()){
            VALUES("status", "#{status, jdbcType=INTEGER}");
        }
        if(null != channelNet.getCreateTime()){
            VALUES("create_time", "#{createTime, jdbcType=TIMESTAMP}");
        }
        if(null != channelNet.getModifyTime()){
            VALUES("modify_time", "#{modifyTime, jdbcType=TIMESTAMP}");
        }

        return SQL();
    }

    public String updateSelective(ChannelNet channelNet){

        BEGIN();
        UPDATE("channel_net");

        if(StringUtils.hasLength(channelNet.getAccount())){
            SET("account=#{account, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getAccountName())){
            SET("account_name=#{accountName, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getPassword())){
            SET("password=#{password, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getChannelDic())){
            SET("channel_dic=#{channelDic, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getChannelType())){
            SET("channel_type=#{channelType, jdbcType=VARCHAR}");
        }
        if(StringUtils.hasLength(channelNet.getCorpCode())){
            SET("corp_code=#{corpCode, jdbcType=VARCHAR}");
        }
        if(null != channelNet.getAddUser()){
            SET("add_user=#{addUser, jdbcType=INTEGER}");
        }
        if(null != channelNet.getStatus()){
            SET("status=#{status, jdbcType=INTEGER}");
        }
        if(null != channelNet.getModifyTime()){
            SET("modify_time=#{modifyTime, jdbcType=TIMESTAMP}");
        }

        WHERE("id = #{id,jdbcType=INTEGER}");

        return SQL();
    }

}
